/**
 * 猪哥亮开源
 * 作者 猪哥亮
 * 邮箱 1030681978@qq.com
 */
package cn.jnetty.ioc.factorys;
import cn.jnetty.ioc.factorys.config.BeanDefinition;
import cn.jnetty.ioc.factorys.config.BeanFactory;
import cn.jnetty.ioc.factorys.support.GenericBeanDefinition;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * @author 猪哥亮
 * @email 1030681978@qq.com
 * @date 2020/7/6 16:17
 * 描述： 
 *
 */
public class DefaultListableBeanFactory implements BeanFactory {
    /**三级缓存*/
    private Map<String, GenericBeanDifintionFactory> beanDifintionFactoryMap = new HashMap<>(256);
    /**二级缓存 是否正在创建bean*/
    private Set<String> beanNameSet = new HashSet<>(256);
    /**一级缓存*/
    private Map<String, GenericBeanDefinition> singletonObjectMap = new HashMap<>(256);
    public void addeanDifintionFactory(GenericBeanDifintionFactory difintionFactory){
        if(this.beanDifintionFactoryMap.containsKey(difintionFactory.getDefinition().getBeanClassName())){

        }
        this.beanDifintionFactoryMap.put(difintionFactory.getDefinition().getBeanClassName(),difintionFactory);
    }
    @Override
    public BeanDefinition getBeanDefinition(String beanName) {
        return singletonObjectMap.get(beanName);
    }

    @Override
    public Object getObject(String beanName) {
        GenericBeanDefinition o;
        return (o = singletonObjectMap.get(beanName)) == null ? null : o.getObj();
    }

    @Override
    public Object getObject(Class<?> clazz) {
        return null;
    }
}
